import { request } from '@/service/request';
import type { NoticeSearchParams, NoticeVO, System } from '@/service/types/system';

export function getPageList(params?: NoticeSearchParams) {
  return request<System.NoticeVo>({
    url: '/system/notice/list',
    method: 'get',
    params
  });
}

export function getNotice(id: number) {
  return request<NoticeVO>({
    url: `/system/notice/${id}`,
    method: 'get'
  });
}

export function addNotice(data: NoticeVO) {
  return request({
    url: '/system/notice',
    method: 'post',
    data
  });
}

export function editNotice(data: NoticeVO) {
  return request({
    url: '/system/notice',
    method: 'put',
    data
  });
}

export function delNotice(id: number | number[]) {
  return request({
    url: `/system/notice/${id}`,
    method: 'delete'
  });
}

export function sendNotice(id: number) {
  return request({
    url: `/system/notice/send/${id}`,
    method: 'PUT'
  });
}

export function closeNotice(id: number) {
  return request({
    url: `/system/notice/close/${id}`,
    method: 'DELETE'
  });
}

export function getMeNotice(params?: NoticeSearchParams) {
  return request<System.NoticeVo>({
    url: '/system/notice/me',
    method: 'get',
    params
  });
}

export function readNotice(id: number) {
  return request({
    url: `/system/notice/read/${id}`,
    method: 'PUT'
  });
}

export function getReadDot() {
  return request({
    url: `/system/notice/dot`,
    method: 'GET'
  });
}
